#include<iostream>
#include<queue>
#include<vector>

using namespace std;

int n, p;
void solve(){
    cin >> p >>  n;
    cout << p << " " << (n + 1) / 2 << '\n';
    priority_queue<int, vector<int>, greater<int>> bigq; //小根
    priority_queue<int, vector<int>, less<int>> smaq;   //大根
    vector<int> ans;
    for(int i = 1, x; i <= n; i ++){
        cin >> x;
        if(i == 1){
            smaq.push(x);
            ans.push_back(smaq.top());
            continue;
        }
        if(x < smaq.top()){
            smaq.push(x);
        }else{
            bigq.push(x);
        }

        if(i % 2 == 0){
            if(smaq.size() > bigq.size()){
                bigq.push(smaq.top());
                smaq.pop();
            }else if(smaq.size() < bigq.size()){
                smaq.push(bigq.top());
                bigq.pop();
            }
        }

        if(i % 2){

            if(smaq.size() < bigq.size()){
                smaq.push(bigq.top());
                bigq.pop();
            }
            ans.push_back(smaq.top());
            // cout << smaq.size() << " " << bigq.size() << '\n';

        }
        

            
    
    }
    for(int i = 1; i <= ans.size(); i ++){
        cout << ans[i - 1] << " ";
        if(i % 10 == 0 && i != ans.size()) cout << '\n';
    }
    if(!ans.empty()) cout << '\n';
}

int main(){

    int T;
    cin >> T;
    while(T--){

        
        solve();
    }
}